{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "original\n",
      "5\n",
      "(4, 5, 6)\n",
      "[1, 2, 3, 4]\n",
      "{'key': 'value', 'new_key': 'new_value'}\n",
      "99\n"
     ]
    }
   ],
   "source": [
    "# 字符串  \n",
    "def modify_string(s):  \n",
    "    s = \"modified\"  \n",
    "  \n",
    "original_string = \"original\"  \n",
    "modify_string(original_string)  \n",
    "print(original_string)  # 输出: original  \n",
    "  \n",
    "# 数字  \n",
    "def modify_number(n):  \n",
    "    n = 10  \n",
    "  \n",
    "original_number = 5  \n",
    "modify_number(original_number)  \n",
    "print(original_number)  # 输出: 5  \n",
    "  \n",
    "# 元组  \n",
    "def modify_tuple(t):  \n",
    "    t = (1, 2, 3)  \n",
    "  \n",
    "original_tuple = (4, 5, 6)  \n",
    "modify_tuple(original_tuple)  \n",
    "print(original_tuple)  # 输出: (4, 5, 6)  \n",
    "  \n",
    "# 列表  \n",
    "def modify_list(lst):  \n",
    "    lst.append(4)  \n",
    "  \n",
    "original_list = [1, 2, 3]  \n",
    "modify_list(original_list)  \n",
    "print(original_list)  # 输出: [1, 2, 3, 4]  \n",
    "  \n",
    "# 字典  \n",
    "def modify_dict(d):  \n",
    "    d['new_key'] = 'new_value'  \n",
    "  \n",
    "original_dict = {'key': 'value'}  \n",
    "modify_dict(original_dict)  \n",
    "print(original_dict)  # 输出: {'key': 'value', 'new_key': 'new_value'}  \n",
    "  \n",
    "# 自定义对象  \n",
    "class CustomObject:  \n",
    "    def __init__(self, value):  \n",
    "        self.value = value  \n",
    "  \n",
    "    def modify_value(self, new_value):  \n",
    "        self.value = new_value  \n",
    "  \n",
    "def modify_object(obj):  \n",
    "    obj.modify_value(99)  \n",
    "  \n",
    "original_object = CustomObject(1)  \n",
    "modify_object(original_object)  \n",
    "print(original_object.value)  # 输出: 99"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Positional arguments:\n",
      "1\n",
      "2\n",
      "3\n",
      "\n",
      "Keyword arguments:\n",
      "a: apple\n",
      "b: banana\n",
      "c: cherry\n"
     ]
    }
   ],
   "source": [
    "def print_all_args(*args, **kwargs):  \n",
    "    # 打印所有位置参数  \n",
    "    print(\"Positional arguments:\")  \n",
    "    for arg in args:  \n",
    "        print(arg)  \n",
    "      \n",
    "    # 打印所有关键字参数  \n",
    "    print(\"\\nKeyword arguments:\")  \n",
    "    for key, value in kwargs.items():  \n",
    "        print(f\"{key}: {value}\")  \n",
    "  \n",
    "# 调用函数并传递不同类型的参数  \n",
    "print_all_args(1, 2, 3, a='apple', b='banana', c='cherry')"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "base",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
